<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
<%@ taglib prefix="dgg" uri="/dgg-tags" %>
<div class="layer-warp">
    <c:if test="${!empty order}">
        <div>
            <table class="titleTable add-table">
                <tbody>
                <input type="hidden" id="orderId" value="${order.orderId}">
                <tr>
                    <th><span class="form-label ">客户名称：</span></th>
                    <td>${order.customerName}
                        <span>(</span>
                        <dgg:ennumber number="${order.customerPhone}"/>
                        <span>)</span>
                    </td>
                    <th><span class="form-label ">订单编号：</span></th>
                    <td>${order.orderNo}</td>
                </tr>
                <tr>
                    <th><span class="form-label ">办理业务：</span></th>
                    <td>${productNames}</td>
                    <th><span class="form-label ">签单商务：</span></th>
                    <td>${order.signUserName}</td>
                </tr>
                <tr>
                    <th><span class="form-label ">签单时间：</span></th>
                    <td><fmt:formatDate value="${order.signDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                    <th><span class="form-label ">订单金额：</span></th>
                    <td>${order.money}元</td>
                </tr>
                </tbody>
            </table>
        </div>
    </c:if>

    <c:if test="${!empty list}">
        <div class="popups-info" id="allotBox">
            <table class="layui-table">
                <thead>
                <tr>
                    <th>生产订单编号</th>
                    <th>生产订单状态</th>
                    <th>办理业务</th>
                    <th>最新节点</th>
                    <th>流程人员</th>
                    <th>所在部门</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${list}" var="o">
                    <tr>
                        <td>${o.scProductOrderNo}</td>
                        <td>${o.status}</td>
                        <td>${o.procuctName}</td>
                        <td>${o.lastestEndNodeName}</td>
                        <td>${o.flowUserName}</td>
                        <td>${o.flowUserOrgName}</td>
                    </tr>
                </c:forEach>

                </tbody>
            </table>
        </div>
    </c:if>


    <div class="distribPersonel popups-info" id="allotBox">
        <table class="add-table form-table">
            <tr>
                <th><span class="form-label required">分配方式：</span></th>
                <td>
                    <div class="layui-input-inline select2-inline">
                        <select class='select-style' name="allotWay" id="allotWay">
                            <option value="">请选择</option>
                            <option value="${ALLOT_TO_FLOW_USER}">分配给生产人</option>
                            <option value="${ALLOT_TO_PRODUCT_USER}">分配给负责人</option>
                        </select>
                    </div>
                </td>
            </tr>
            <tr>
                <th><span class="form-label required">选择分配人员：</span></th>
                <td>
                    <div class="layui-input-inline select2-inline" id="flowUserIdDiv">
                        <select style="width: 240px;" id="flowUserId" name="flowUserId" class="flowUserId">
                            <option value>请选择</option>
                        </select>
                    </div>
                </td>
            </tr>
            <tr>
                <th><span class="form-label">选择协单人员：</span></th>
                <td>
                    <div class="layui-input-inline select2-inline">
                        <select id="assistId" name="assistId" class="assistId">
                        </select>
                    </div>
                </td>
            </tr>
            <tr>
                <th><span class="form-label required">合同开始时间：</span></th>
                <td>
                    <div class="layui-inline">
                        <input type="text" name="contractStartTime" placeholder="开始时间" class="Wdate input-style" id="d4313"
                               onFocus="WdatePicker({onpicked:function(){d4314.focus();}, maxDate:'#F{ $dp.$D(\'d4314\')}', dateFmt:'yyyy-MM-dd'})">
                    </div>
                </td>
            </tr>
            <tr>
                <th><span class="form-label required">合同结束时间：</span></th>
                <td>
                    <div class="layui-inline">
                        <input type="text" name="contractEndTime" placeholder="结束时间" class="Wdate input-style" id="d4314"
                               onFocus="WdatePicker({minDate:'#F{$dp.$D(\'d4313\')}', dateFmt:'yyyy-MM-dd'})">
                    </div>
                </td>
            </tr>
            <tr>
                <th><span class="form-label">备注：</span></th>
                <td>
                    <textarea class="textarea-style" rows="4" name="lastRemark" id="lastRemark" placeholder="500字以内"></textarea>
                </td>
            </tr>
        </table>
    </div>
</div>
<script src="${rootUrl}/static/js/zzsc/common/sc_chooseUser.js?v=${version}" type="text/javascript"
        charset="utf-8"></script>
<script type="text/javascript">
    $(function () {
        //訂單分配人員的初始化下拉数据
        $(document).ready(function () {
            areaLength($('#lastRemark'),500);
            $("#allotWay").change(function () {
                $("#flowUserIdDiv").html("").append("<select style=\"width: 240px;\"  id=\"flowUserId\" name=\"flowUserId\" class = \"flowUserId\">" +
                    "                            <option value>请选择</option>" +
                    "                        </select>");
                var allotWay = $("#allotWay").val();
                if (allotWay=="SC_GENERAL_ALLOT03"){
                    chooseUserPlug.init($('.flowUserId'), {
                        url: sysInfo.basePath + '/zzsc/common/find_user_choose.do',
                        width: '240px',
                        // multiple:true,// 单选false或不写该参数，多选true
                        otherParam: {
                            roleName:'ZZSC_HTMANAGER',
                            /**
                             * type: 用户信息选择类型（必填）
                             *       all:全部用户，division：当前登录人所在事业部，department:当前登录人所在部门及以下，role: 查询指定角色用户，
                             * roleCode : 角色Code，（type为role时，必填）
                             * locked: 用户状态，（选填，默认全部状态）
                             *      0、正常；1、锁定；2、离职
                             */
                            organId:'${productOrderInfo.productOrgId}',//查询订单生产所属事业部下的角色人员
                            locked:'0'
                        }

                    });
                } else {
                    chooseUserPlug.init($('.flowUserId'), {
                        url: sysInfo.basePath + '/zzsc/common/find_user_choose.do',
                        width: '240px',
                        // multiple:true,// 单选false或不写该参数，多选true
                        otherParam: {
                            /**
                             * type: 用户信息选择类型（必填）
                             *       all:全部用户，division：当前登录人所在事业部，department:当前登录人所在部门及以下，role: 查询指定角色用户，
                             * roleCode : 角色Code，（type为role时，必填）
                             * locked: 用户状态，（选填，默认全部状态）
                             *      0、正常；1、锁定；2、离职
                             */
                            organId:'${productOrderInfo.productOrgId}',//查询订单生产所属事业部下的角色人员
                            locked:'0'
                        }

                    });
                }
            });
        });
        //初始化協單人員
        chooseUserPlug.init($('.assistId'), {
            width: '240px',
            url: sysInfo.basePath + '/zzsc/common/find_user_choose.do',
            multiple: true,// 单选false或不写该参数，多选true
            allowClear: false,
            otherParam: {
                /**
                 * type: 用户信息选择类型（必填）
                 *       all:全部用户，division：当前登录人所在事业部，department:当前登录人所在部门及以下，role: 查询指定角色用户，
                 * roleCode : 角色Code，（type为role时，必填）
                 * locked: 用户状态，（选填，默认全部状态）
                 *      0、正常；1、锁定；2、离职
                 */
                // type:'division',
                organId: '${productOrderInfo.productOrgId}',//查询订单生产所属事业部下的角色人员
                locked: 0
            },
            yesFun: function () {
                dgg.relocation($('.layerIndex2').val());
            }
        });
        var ids = '${ids}';
        console.log(ids);
        var idStr = ids.split(",");
        $("#assistId").val(idStr).trigger("change");
        $('#assistId').on('select2:select', function () {
            dgg.relocation($('.layerIndex2').val());
        });
    });
</script>